import request from './request'
import { useUserStore } from '../store/modules/user'
import { AxiosPromise } from 'axios'

// 获取部门人员及地址下拉数据
export function getNetworkEmpAddressPageSelect(data) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/networkSelect/getNetworkEmpAddressPageSelect',
    method: 'post',
    headers: token,
    data,
  })
}

// 获取部门及地址下拉数据
export function getNetworkAddressPageSelect(data) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/networkSelect/getNetworkAddressPageSelect',
    method: 'post',
    headers: token,
    data,
  })
}

//获取仓库列表
export function getListStore(data: object) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/store/getList',
    method: 'post',
    headers: token,
    data,
  })
}
//批量修改允许或不允许负库存
export function canNegativeStock(data, canNegativeStock) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/store/canNegativeStock?canNegativeStock=' + canNegativeStock,
    method: 'put',
    headers: token,
    data,
  })
}
//批量删除仓库
export function deleteStore(data) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/store/delete',
    method: 'DELETE',
    headers: token,
    data,
  })
}
//批量启用或禁用仓库
export function disableStore(data, status) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/store/disable?status=' + status,
    method: 'put',
    headers: token,
    data,
  })
}
// 根据仓库ID获取仓库详情修改
export function getDetailStore(id) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: `/store/getDetail/${id}`,
    method: 'get',
    headers: token,
  })
}
// 新增或修改仓库
export function saveStore(data) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: `/store/save`,
    method: 'post',
    headers: token,
    data,
  })
}
// 获取仓库列表本月的入-出库的数量
export function getListCurrentMothInWidthOutStoreQty() {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: `/store/getListCurrentMothInWidthOutStoreQty`,
    method: 'get',
    headers: token,
  })
}
// 根据仓库ID获取仓库库存明细
export function getStoreDetailGoodsList(data, id) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: `/store/getStoreDetailGoodsList/` + id,
    method: 'post',
    headers: token,
    data,
  })
}
// 根据仓库ID获取仓位列表
export function getStorePositionList(data, id) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: `/store/getStorePositionList/` + id,
    method: 'post',
    headers: token,
    data,
  })
}
// 根据仓位ID获取仓位库存明细
export function getStorePositionDetailGoodsList(data, id) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: `/store/getStorePositionDetailGoodsList/` + id,
    method: 'post',
    headers: token,
    data,
  })
}
// 设置
// 获取仓库类型列表
export function getStoreTypeList(data) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: `/store/type/getList`,
    method: 'post',
    headers: token,
    data,
  })
}
// 新增或修改仓库类型
export function addStoreType(data) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: `/store/type/save`,
    method: 'post',
    headers: token,
    data,
  })
}
//批量删除仓库类型
export function deleteStoreType(data) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/store/type/delete',
    method: 'DELETE',
    headers: token,
    data,
  })
}
//批量启用或禁用仓库类型
export function disableStoreType(data, status) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/store/type/disable?status=' + status,
    method: 'put',
    headers: token,
    data,
  })
}
// 根据仓库类型ID获取详情
export function getDetailStoreType(id) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: `/store/type/getDetail/${id}`,
    method: 'get',
    headers: token,
  })
}

/**
 * 获取设备库存
 * @param {Object} data - 请求参数
 * @param {String} data.goodsId - 设备ID
 * @param {String} data.goodsSpecId - 设备规格ID
 * @param {String} data.storeId - 仓库ID
 * @param {String} data.storePositionId - 仓库仓位ID
 * @param {(1|2)} data.type - 设备类型：1-成品，2-物料
 */
export function getGoodsStock(
  data: StorageAPIRequest.GetWarehouseGoodStock,
): AxiosPromise<WarehouseOutAPIResponse.GoodStock> {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: `/store/goods/stock/getGoodsStock`,
    method: 'post',
    headers: token,
    data,
  })
}

/**
 * 仓库下拉列表查询
 * @param {Object} data - 请求参数
 * @param {String} data.name - 搜索关键字
 * @param {Number} data.limit - 一页显示多少条
 * @param {Number} data.page - 页码
 * @param {string} data.id - ID搜索
 * @param {(0|1|2)} warehouseType - 仓库类型
 */
export function storePageSelect(
  data: { name: string; page: number; limit: number; id: string },
  warehouseType: 0 | 1 | 2,
): AxiosPromise<WarehouseOutAPIResponse.WarehouseOptionList> {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/store/select/storePageSelect/' + warehouseType,
    method: 'post',
    headers: token,
    data,
  })
}

/**
 * 根据仓库ID获取仓位下拉列表
 * @param {Object} data - 请求参数
 * @param {String} data.name - 搜索关键字
 * @param {Number} data.limit - 一页显示多少条
 * @param {Object} data.page - 页码
 */
export function storePositionPageSelect(
  data: { name: string; limit: number; page: number },
  storeId: string,
): AxiosPromise<WarehouseOutAPIResponse.WarehousePositionOptionList> {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/store/select/storePositionPageSelect/' + storeId,
    method: 'post',
    headers: token,
    data,
  })
}

/**
 * 仓库及人员地址下拉列表查询
 * @param {Object} data - 请求参数
 * @param {String} data.name - 搜索关键字
 * @param {Number} data.page - 页码
 * @param {Number} data.limit - 一页显示多少条
 * @param {Number} data.id - ID搜索
 * @param {(0|1|2)} storeType - 仓库类型：0-内部仓库，1-服务商-外部仓库，2-工程师-外部仓库
 */
export function storeEmpAddressPageSelect(
  data: { limit: number; page: number; name: string; id: string },
  storeType: 0 | 1 | 2,
): AxiosPromise<WarehouseOutAPIResponse.WarehouseAndPersonAddressList> {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/store/select/storeEmpAddressPageSelect/' + storeType,
    method: 'post',
    headers: token,
    data,
  })
}

/**
 * 获取出库列表
 * @param {StorageAPIRequest.GetWarehouseOutList} data - 请求参数
 * @param {'' | 1 | 2 | 3 | 4 | 5} data.dateType - 日期类型：1-时间区间，2-今天，3-本周，4-本月，5-过去在个月
 * @param {string} data.endTime - 结束时间
 * @param {number} data.limit - 	每页显示数量
 * @param {number} data.page - 当面页码
 * @param {string} data.search - 关键词搜索：出库单列表搜索支持：出库单号/收货人/收货人手机号/制单人；入库单列表搜索支持：出库单号/制单人
 * @param {'' | 1 | 2 | 3 | 4 | 5} data.source - 单据来源：1-系统单，2-工单，3-ERP单据，4-仓库移动端单据，5-第三方系统单据
 * @param {string} data.startTime - 开始时间
 * @param {'' | 1 | 2 | 3 | 4 | 5} data.status - 1-待审核，2-待出库/待发货，3-驳回，4-已完成/已出库，5-已作废/取消
 * @param {string} data.typeId - 出/入库类型ID
 * @returns {AxiosPromise<WarehouseOutAPIResponse.WarehouseOutList>} - 出库列表
 */
export function outboundList(
  data: StorageAPIRequest.GetWarehouseOutList,
): AxiosPromise<WarehouseOutAPIResponse.WarehouseOutList> {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/store/outbound/getList',
    method: 'post',
    headers: token,
    data,
  })
}

/**
 * 出库仓库类型下拉列表查询
 * @param {Object} data - 请求参数
 * @param {String} data.name - 搜索关键字
 * @param {Number} data.limit - 每页显示多少条
 * @param {Number} data.page - 页码
 */
export function outStoreTypePageSelect(data: {
  limit: number
  page: number
  name: string
}): AxiosPromise<WarehouseOutAPIResponse.WarehouseTypeOptionList> {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/store/select/outStoreTypePageSelect',
    method: 'post',
    headers: token,
    data,
  })
}

/**
 * 根据出库单ID获取出库详情
 * @param id - 出库单id
 */
export function getOutboundDetail(
  id: string,
): AxiosPromise<WarehouseOutAPIResponse.DetailBeforeCheck> {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/store/outbound/getOutboundDetail/' + id,
    method: 'get',
    headers: token,
  })
}

/**
 * 根据出库单ID获取出库物料
 * @param id - 出库单id
 */
export function getOutboundMaterial(
  id: string,
): AxiosPromise<WarehouseOutAPIResponse.MaterialList> {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/store/outbound/getOutboundMaterial/' + id,
    method: 'get',
    headers: token,
  })
}

/**
 * 保存或审核出库单
 * @param {StorageAPIRequest.WarehouseOutFormSave} data - 请求参数
 * @param {(1|2)} submitType - 提交类型：1-保存，2-审核
 */
export function saveOrCheck(
  data: StorageAPIRequest.WarehouseOutFormSave,
  submitType: 1 | 2,
): AxiosPromise<APIResponse> {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/store/outbound/saveOrCheck/' + submitType,
    method: 'post',
    headers: token,
    data,
  })
}

// 作废出库单
export function cancelStoreOutbound(data, id) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/store/outbound/cancelStoreOutbound/' + id,
    method: 'post',
    headers: token,
    data,
  })
}

/**
 * 获取在库的序列号
 * @param {Object} data - 请求参数
 * @param {String} data.goodsId - 设备ID
 * @param {String} data.goodsSpecId - 设备规格ID
 * @param {String} data.keyword - 搜索关键词:序列号
 * @param {Number} data.limit - 每页显示数量
 * @param {Number} data.page - 当面页码
 * @param {String} data.storeId - 仓库ID
 * @param {String} data.storePositionId - 仓库仓位ID
 * @param {(1|2)} data.type - 类型:1-成品,2-物料
 */
export function getInStoreCodeList(
  data: CodeAPIRequest.GetInWarehouseSnCodeList,
): AxiosPromise<WarehouseOutAPIResponse.InWarehouseSnCodeList> {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/store/outbound/getInStoreCodeList',
    method: 'post',
    headers: token,
    data,
  })
}

// 确认出库
export function saveSureStoreOutbound(data, id) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/store/outbound/saveSureStoreOutbound/' + id,
    method: 'post',
    headers: token,
    data,
  })
}

/**
 * 获取出入库设备
 * @param {StorageAPIRequest.GetWarehouseOutGoodList} data - 请求参数
 * @param {(1|2)} type - 设备类型：1-成品，2-物料
 */
export function getInOrOutStoreGoods(
  data: StorageAPIRequest.GetWarehouseOutGoodList,
  type: 1 | 2,
): AxiosPromise<WarehouseOutAPIResponse.GoodList> {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: `/goods/product/getInOrOutStoreGoods/${type}`,
    method: 'post',
    headers: token,
    data,
  })
}

/**
 * 根据入库单ID获取入库单详情
 * @param {String} id 入库单id
 */
export function getInboundDetail(id: string): AxiosPromise<WarehouseEntryAPIResponse.Detail> {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/store/inbound/getInboundDetail/' + id,
    method: 'get',
    headers: token,
  })
}

/**
 * 根据入库单ID获取入库单详情物料
 * @param {String} id - 入库单id
 */
export function getInboundDetailMaterial(
  id: string,
): AxiosPromise<WarehouseEntryAPIResponse.DetailGoodList> {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/store/inbound/getInboundDetailMaterial/' + id,
    method: 'get',
    headers: token,
  })
}

/**
 * 获取入库列表
 * @param {Object} data - 请求参数
 */
export function inboundList(
  data: StorageAPIRequest.GetWarehouseInListParam,
): AxiosPromise<WarehouseEntryAPIResponse.List> {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/store/inbound/getList',
    method: 'post',
    headers: token,
    data,
  })
}

// 获取未出入库的序列号
export function getStoreCodeList(data) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/store/inbound/getStoreCodeList',
    method: 'post',
    headers: token,
    data,
  })
}
// 保存或保存并审核入库单
export function saveinboundCheck(data, submitType): AxiosPromise<APIResponse> {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/store/inbound/save/' + submitType,
    method: 'post',
    headers: token,
    data,
  })
}

//确认入库
export function saveSureStoreInbound(data, id) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/store/inbound/saveSureStoreOutbound/' + id,
    method: 'post',
    headers: token,
    data,
  })
}

/**
 * 入库仓库类型下拉列表查询
 * @param {Object} data - 请求参数
 * @param {Number} data.limit - 一页显示多少条
 * @param {Number} data.page - 页码
 * @param {String} data.name - 搜索关键字
 */
export function inStoreTypePageSelect(data: {
  name: string
  limit: number
  page: number
}): AxiosPromise<WarehouseEntryAPIResponse.DocumentTypeOptions> {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/store/select/inStoreTypePageSelect',
    method: 'post',
    headers: token,
    data,
  })
}

//获取物流下拉列表
export function getLogisticsSelectList(data) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/system/logistics/getLogisticsSelectList',
    method: 'post',
    headers: token,
    data,
  })
}

/**
 * 获取出库收货公司信息
 * @param {Object} data - 请求参数
 * @param {String} data.name - 搜索关键字
 * @param {Number} data.page - 页码
 * @param {Number} data.limit - 一页显示多少条
 */
export function getOutStoreReceiptsUser(data: {
  limit: number
  page: number
  name: string
}): AxiosPromise<WarehouseOutAPIResponse.ReceiptCustomerList> {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/store/outbound/getOutStoreReceiptsUser',
    method: 'post',
    headers: token,
    data,
  })
}

/**
 * 驳回出库单
 * @param {Object} data - 驳回表单
 * @param {String} data.remark - 驳回备注
 * @param {String} id - 出库单id
 */
export function rejectOutbound(data: { remark: string }, id: string): AxiosPromise<APIResponse> {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/store/outbound/rejectOutbound/' + id,
    method: 'post',
    headers: token,
    data,
  })
}

/**
 * 驳回入库单
 * @param {Object} data - 驳回表单
 * @param {String} data.remark - 驳回备注
 * @param {String} id - 入库单id
 */
export function rejectInbound(data: { remark: string }, id: string): AxiosPromise<APIResponse> {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/store/inbound/rejectInbound/' + id,
    method: 'post',
    headers: token,
    data,
  })
}

// 作废入库单
export function cancelStoreInbound(data, id) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/store/inbound/cancelStoreInbound/' + id,
    method: 'post',
    headers: token,
    data,
  })
}
/**库存查询列表 */
export function getStockList(data) {
  return request({
    url: '/store/store/getStockList',
    method: 'post',
    data,
  })
}

/**
 * 获取仓库下拉数据
 * @param {Object} data - 请求参数
 * @param {number} data.limit - 每页显示数量
 * @param {number} data.page - 当面页码
 * @param {string} data.name - 搜索关键词
 * @param {string} data.id - ID搜索
 */
export function getStorePageSelect(data: {
  limit: number
  page: number
  name: string
  id: string
}): AxiosPromise<WarehouseAPIResponse.WarehouseOptionList> {
  return request({
    url: '/store/select/getStorePageSelect',
    method: 'post',
    data,
  })
}

/**
 * 获取部门仓库
 * @param id - 部门id
 */
export const getNetworkWarehouse = (
  id: string,
): AxiosPromise<WarehouseAPIResponse.WarehouseInfoByNetworkId> => {
  return request({
    url: `/store/getNetworkStore/${id}`,
    method: 'get',
  })
}

/**
 * 旧件退库-分页
 * @param params - 查询数据
 */
export const inboundOldPage = (params) => {
  return request({
    url: `/store/inbound/old/spare/page`,
    method: 'get',
    params,
  })
}

/**
 * 旧件退库-详情
 * @param id - id
 */
export const inboundOldDetail = (id) => {
  return request({
    url: `/store/inbound/old/spare/getById/${id}`,
    method: 'get',
  })
}

/**
 * 旧件退库-批量审核
 * @param data - ids
 */
export const udpateApplyByIds = (data) => {
  return request({
    url: `/store/inbound/old/spare/udpateApplyByIds`,
    method: 'post',
    data,
  })
}

/**
 * 旧件退库-批量修改物流信息
 * @param {StorageAPIRequest.OldPartMultipleReturn} data - 请求参数
 * @param {Array<string>} data.ids - id 列表
 * @param {string} data.logisticsCode - 物流公司单号
 * @param {string} data.logisticsCorpName - 物流公司
 */
export const updateLogisticsByIds = (
  data: StorageAPIRequest.OldPartMultipleReturn,
): AxiosPromise<APIResponse> => {
  return request({
    url: `/store/inbound/old/spare/updateLogisticsByIds`,
    method: 'post',
    data,
  })
}

/**
 * 旧件退库-批量收货
 * @param data - ids
 */
export const updateOrderState = (data) => {
  return request({
    url: `/store/inbound/old/spare/updateOrderState`,
    method: 'post',
    data,
  })
}

/**
 * 批量反写工单物料出库单到星空的其他出库单
 * @param {Array<string>} idList - 出库单id集合
 * @param {1|2} type - 反写类型：1-其他出库反写，2-调拨出库反写
 */
export const warehouseOutWriteBack = (
  idList: Array<string>,
  type: 1 | 2,
): AxiosPromise<APIResponse> => {
  return request({
    url: `/store/outbound/writeBackWorkMaterialOutbound/${type}`,
    method: 'post',
    data: idList,
  })
}

/**
 * 获取所有的仓库下拉选项
 * @param {Object} data - 请求参数
 * @param {string} data.id - ID搜索
 * @param {number} data.limit - 每页显示数量
 * @param {string} data.name - 搜索关键词
 * @param {number} data.page - 当面页码
 */
export const getAllWarehouseOptionList = (data: {
  id: string
  limit: number
  page: number
  name: string
}): AxiosPromise<WarehouseAPIResponse.AllWarehouseOptionList> => {
  return request({
    url: '/store/select/getAllStore',
    method: 'post',
    data,
  })
}

/**
 * 新增调拨入-出库单
 * @param {StorageAPIRequest.AllotWarehouseInOrOutForm} data - 请求参数
 * @param {1|2} type - 调拨类型：2-调拨入库单， 3-调拨出库单
 * @param {0|1} submitType 提交类型：0-提交，1-仅保存
 */
export const allotWarehouseInOrOutFormSave = (
  data: StorageAPIRequest.AllotWarehouseInOrOutForm,
  type: 2 | 3,
  submitType: 0 | 1,
): AxiosPromise<APIResponse> => {
  return request({
    url: `/store/transfer/saveTransferInStore/${type}/${submitType}`,
    method: 'post',
    data,
  })
}

/**
 * 调拨校验序列号
 * @param {StorageAPIRequest.AllotCheckSnCodeForm} data - 校验表单
 */
export const checkWarehouseGoodSnCode = (
  data: StorageAPIRequest.AllotCheckSnCodeForm,
): AxiosPromise<APIResponse> => {
  return request({
    url: '/store/transfer/checkStoreSnCodes',
    method: 'post',
    data,
  })
}

/**
 * 获取调拨入库列表
 * @param {StorageAPIRequest.GetAllotInWarehouseListParam} data - 请求参数
 */
export const getAllotInWarehouseList = (
  data: StorageAPIRequest.GetAllotInWarehouseListParam,
): AxiosPromise<WarehouseAPIResponse.AllotInWarehouseList> => {
  return request({
    url: '/store/transfer/getTransferInStoreList',
    method: 'post',
    data,
  })
}

/**
 * 获取调拨入库单详情
 * @param {string} id - 入库单id
 */
export const getAllotInWarehouseDetail = (
  id: string,
): AxiosPromise<WarehouseAPIResponse.AllotInWarehouseDetail> => {
  return request({
    url: `/store/transfer/getTransferInStoreDetail/${id}`,
    method: 'get',
  })
}

/**
 * 获取调拨入库单详情的物料
 * @param {string} id - 调拨入库单id
 */
export const getAllotInWarehouseDetailMaterialList = (
  id: string,
): AxiosPromise<WarehouseAPIResponse.AllotInWarehouseDetailMaterialList> => {
  return request({
    url: `/store/transfer/getOutboundMaterial/${id}`,
    method: 'get',
  })
}

/**
 * 修改调拨入库
 * @param {StorageAPIRequest.AllotWarehouseInOrOutForm} data - 请求参数
 * @param {string} id - 调拨入库单id
 * @param {0|1} submitType - 提交类型：0-提交，1-仅保存
 */
export const updateAllotInWarehouse = (
  data: StorageAPIRequest.AllotWarehouseInOrOutForm,
  id: string,
  submitType: 0 | 1,
): AxiosPromise<APIResponse> => {
  return request({
    url: `/store/transfer/updateTransferInStore/${id}/${submitType}`,
    method: 'post',
    data,
  })
}

/**
 * 审核调拨出库
 * @param {string} id - 出库id
 * @param {StorageAPIRequest.CheckAllotOutWarehouse} data - 请求参数
 */
export const checkAllotOutWarehouse = (
  id: string,
  data: StorageAPIRequest.CheckAllotOutWarehouse,
): AxiosPromise<APIResponse> => {
  return request({
    url: `/store/transfer/checkTransferOutStore/${id}/`,
    method: 'post',
    data,
  })
}

/**
 * 获取当前账号所在部门的部门信息和仓库信息
 */
export const getCurrentAccountsNetworkInWarehouse =
  (): AxiosPromise<WarehouseAPIResponse.CurrentAccountsNetworkINWarehouse> => {
    return request({
      url: '/store/outbound/getNetworkInStore',
      method: 'get',
    })
  }

/**
 * 获取调拨出库列表
 * @param {StorageAPIRequest.GetAllotOutWarehouseListParam} data - 请求参数
 * @param {1|2|3|4|5} data.dateType - 日期类型：1-时间区间，2-今天，3-本周，4-本月，5-过去在个月
 * @param {string} data.endTime - 结束时间
 * @param {number} data.limit - 每页显示数量
 * @param {number} data.page - 当面页码
 * @param {Array<string>} data.receiptStoreIds - 收货仓库ID
 * @param {string} data.search - 关键词搜索：出库单列表搜索支持：出库单号/收货人/收货人手机号/制单人；入库单列表搜索支持：出库单号/制单人
 * @param {1|2|3|4|5} data.source - 单据来源：1-系统单，2-工单，3-ERP单据，4-仓库移动端单据，5-第三方系统单据
 * @param {string} data.startTime - 开始时间
 * @param {1|2|3|4|5} data.status - 状态搜索：出库单列表状态搜索：1-待审核，2-待出库/待发货，3-驳回，4-已完成/已出库，5-已作废/取消；入库单列表状态搜索：1-待审核，2-待入库/待收货，3-驳回，4-已完成/已入库，5-已作废
 * @param {Array<string>} data.storeIds - 发货仓库ID
 * @param {string} data.typeId - 出/入库类型ID
 */
export const getAllotOutWarehouseList = (
  data: StorageAPIRequest.GetAllotOutWarehouseListParam,
): AxiosPromise<WarehouseAPIResponse.AllotOutWarehouseList> => {
  return request({
    url: '/store/transfer/getTransferOutStoreList',
    method: 'post',
    data,
  })
}

/**
 * 调拨入库签收
 * @param {Object} data - 请求参数
 * @param {Array<string>} data.ids - 调拨单ID
 * @param {string} data - 备注
 */
export const allotInWarehouseSign = (data: {
  ids: Array<string>
  remark: string
}): AxiosPromise<APIResponse> => {
  return request({
    url: '/store/transfer/saveTransferInStoreSignFor',
    method: 'post',
    data,
  })
}

// 获取调拨入库Excel导出
export function getTransferInStoreExcelExport(data) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/store/transfer/getTransferInStoreExcelExport',
    method: 'post',
    headers: token,
    data,
    responseType: 'blob',
  })
}

// 获取调拨出库库Excel导出
export function getTransferOutStoreExcelExport(data) {
  const token = {
    'access-token': useUserStore().token,
  }
  return request({
    url: '/store/transfer/getTransferOutStoreExcelExport',
    method: 'post',
    headers: token,
    data,
    responseType: 'blob',
  })
}